package com.xiaoke.security.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author 小柯
 * @Date 2019/11/2  16:35
 **/
@RestController
@RequestMapping()
@Slf4j
public class HelloController {


    @GetMapping("hello")
    public String hello() throws Exception {

        log.info("-------");
       // throw  new Exception();
        return "hello xiao ke!";
    }

    @RequestMapping("me")
    public Object getCurrentUser(){
        return SecurityContextHolder.getContext().getAuthentication();
    }
}
